package com.itheima.zhlx.controller;

import com.alibaba.fastjson.JSONObject;
import com.itheima.zhlx.entity.Result;
import com.itheima.zhlx.pojo.Type;
import com.itheima.zhlx.service.impl.TypeServletImpl;
import netscape.javascript.JSObject;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/type")
public class TypeServlet extends BaseServlet {
    private TypeServletImpl typeServlet =new TypeServletImpl();
    public void findAll(HttpServletRequest request,HttpServletResponse response){
        List<Type> types = typeServlet.typeFindAll();
        //System.out.println("1111111111");
        Result result =new Result(true,"查询成功",types);
        try {
            response.getWriter().print(JSONObject.toJSONString(result));
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
